package com.sysmanage.permissions.common;

import java.util.ArrayList;
import java.util.List;

public class MenuJsonItem implements Comparable<MenuJsonItem>{
	
	private String menuid;
	private String menuname;

	private String icon;
	private String url;
	
	private String order;
	private List<MenuJsonItem> menus;
	
	public String getMenuid() {
		return menuid;
	}
	public void setMenuid(String menuid) {
		this.menuid = menuid;
	}
	public String getMenuname() {
		return menuname;
	}
	public void setMenuname(String menuname) {
		this.menuname = menuname;
	}
	
	public String getIcon() {
		return icon;
	}
	public void setIcon(String icon) {
		this.icon = icon;
	}
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	
	public String getOrder() {
		return order;
	}
	public void setOrder(String order) {
		this.order = order;
	}
	public List<MenuJsonItem> getMenus() {
		return menus;
	}
	public void setMenus(List<MenuJsonItem> menus) {
		this.menus = menus;
	}
	public void addMenu(MenuJsonItem item) {
		if(this.menus==null)
		{
			this.menus = new ArrayList<MenuJsonItem>();
		}
		this.menus.add(item);
	}
	public int compareTo(MenuJsonItem obj1)
	{
		if(this.getOrder()==null)
			return  -1;
		Integer order0 =0;
		Integer order1 =0;
		try {
			order0 = Integer.parseInt(this.getOrder());
		} catch (NumberFormatException e) {
			order0 =0;
		}
		try {
			order1 = Integer.parseInt(obj1.getOrder());
		} catch (NumberFormatException e) {
			order1 =0;
		}
		int compareValue = order0.compareTo(order1);
		if(compareValue==0)
		{
			compareValue = this.getMenuname().compareTo(obj1.getMenuname());
		}
		return compareValue;
	}
}
